<?php


namespace App\Models\Wechat;


use App\Commons\Utils\ModelTools\BaseModel;
use App\Models\AdminUser\User;

class MiniProgramDraftToTemplateRecord extends BaseModel {
    protected $dateFormat = 'Y-m-d H:i:s';

    protected $casts = [
        'app_project_type_id' => 'integer',
        'wx_template_id'      => 'integer',
    ];

    protected $searchable = [
        'user_id',
        'wx_draft_id',
        'user_desc',
        'wx_request_result',
        'created_at',
    ];

    //操作是否成功
    const REQUEST_RESULT_SUCCESS = 1;
    const REQUEST_RESULT_FAIL    = 0;

    //是否删除
    const DELETED_NO  = 0;
    const DELETED_YES = 1;

    /**
     * @param $query
     * @return mixed
     */
    public function scopeNoDeleted($query) {
        return $query->where('deleted', self::DELETED_NO);
    }

    /**
     * 关联User用户表
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }
}